public class Test {
    public int maxArea(int[] height) {
        int i = 0;
        int j = height.length - 1;
        int m = 0;
        while (i < j) {
            int v = (j - i) * Math.min(height[i], height[j]);
            m = Math.max(m, v);
            if (height[i] > height[j]) {
                j--;
            } else {
                i++;
            }
        }
        return m;
    }

    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    class Solution {
        public ListNode removeNthFromEnd(ListNode head, int n) {
            ListNode slow = head;
            ListNode fast = head;
            int count = 0;
            while(count<n) {
                fast = fast.next;
                count++;
            }

            ListNode slowPrev = head;
            while(fast!=null) {
                fast = fast.next;
                slowPrev = slow;
                slow = slow.next;
            }

            //删头节点的情况
            if(slow == head) {
                head = head.next;
                return head;
            }

            slowPrev.next = slow.next;
            return head;
        }
    }
}
 